<?php global $has_permit; ?>
<div class="db_left bl">
    <?php $this->load->view('cms/article/side_block'); ?>
</div>
<div class="db_right bl">
    <?php if ($has_permit) :?>
    <div class="std_header auto_height">
        <div class="left">
            <strong><?php echo $module['title']; ?></strong>
        </div>
        <div class="right">
            <button class="gray_btn" onclick="admin_site_tag.create_new()"><span>Thêm mới</span></button>
        </div>
    </div>
    <div id="tag_management">
        <div id="tab_store" class="tab_container">
            <ul>
                <li id="active_tab_list"><a href="#tab_list"><span>Danh sách thẻ</span></a></li>
                <li id="active_tab_edit"><a href="#tab_edit"><span>Thông tin thẻ</span></a></li>
            </ul>
            <div id="tab_list">
                <?php if (count($collection) != 0) : ?>
                <?php $this->load->view('site/tag/message'); ?>
                <form action="<?php echo site_url('admin/site/tag/index', true); ?>" method="post" id="frm_tag_gridview">
                    <div class="block">
                        <table class="gridview" width="100%" cellpadding="0" cellspacing="0" border="0">
                            <thead>
                            <tr>
                                <td><b>ID</b></td>
                                <td><b>Tên</b></td>
                                <td><b>Thao tác</b></td>
                            </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($collection as $tag) : ?>
                            <tr>
                                <input type="hidden" value="" class="edit_url" />
                                <td width="30px" valign="top">
                                    <?php echo $tag->id; ?>
                                </td>
                                <td valign="top">
                                    <?php echo $tag->name; ?>
                                </td>
                                <td valign="top">
                                    <p><a class="icon icon_edit ajax_link" data="{id:<?php echo $tag->id; ?>}" selector="#tab_edit" item="#active_tab_edit a" href="<?php echo site_url('admin/site/tag/ajax_edit/id/' . $tag->id, true); ?>"></a> <a class="icon icon_delete" href="<?php echo site_url('admin/site/tag/delete/id/' . $tag->id, true); ?>" onclick="return confirm('Bạn muốn xóa thẻ này?')"></a></p>
                                </td>
                            </tr>
                                <?php endforeach; ?>
                            </tbody>
                            <tfoot>

                            </tfoot>
                        </table>
                    </div>
                </form>
                <?php else : ?>
                <div class="error_message corner">Không có thẻ nào</div>
                <?php endif; ?>
            </div>
            <div id="tab_edit">
                <form id="frm_tag_edit" method="POST" action="<?php echo $save_action; ?>">
                    <div class="clearfix auto_height mb_10">
                        <button class="gray_btn active_item" type="button" item="#active_tab_list a"><span>Về danh sách</span></button>
                        <button class="gray_btn" type="submit"><span>Lưu lại</span></button>
                        <button class="gray_btn" type="reset"><span>Nhập lại</span></button>
                    </div>
                    <div class="form_block">
                        <div class="block_header">
                            Thông tin căn bản
                        </div>
                        <div class="block_content">
                            <table cellpadding="0px" cellspacing="0px">
                                <tr>
                                    <td class="frm_label">Tên thẻ(*)</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input required" name="data[name]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">URL(*)</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input required" name="data[url]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Thứ tự(*)</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input" name="data[sort_order]" value="0" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Là thẻ đặc biệt(*)</td>
                                    <td class="frm_field">
                                        <label>
                                            <input class="std_chk" type="checkbox" name="data[hot_tag]" value="1" />
                                            <span>Có / Không</span>
                                        </label>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="clearfix auto_height">
                        <button class="gray_btn active_item" type="button" item="#active_tab_list a"><span>Về danh sách</span></button>
                        <button class="gray_btn" type="submit"><span>Lưu lại</span></button>
                        <button class="gray_btn" type="reset"><span>Nhập lại</span></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <?php else :?>
    <?php $this->load->view('layouts/restricted'); ?>
    <?php endif; ?>
</div>
<div class="clearfix"></div>
<script type="text/javascript">
    $("#frm_tag_edit").validate();
</script>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/site/tag/function.js"></script>